//
//  ViewController.m
//  NotificationTest
//
//  Created by 王声远 on 16/6/23.
//  Copyright © 2016年 创美汇. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    CGFloat iPhoneW = [UIScreen mainScreen].bounds.size.width;
    CGFloat iPhoneH = [UIScreen mainScreen].bounds.size.height;
    CGFloat w = 100;
    CGFloat h = 40;
    UIButton *ruleBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.view addSubview:ruleBtn];
    [ruleBtn setFrame:CGRectMake((iPhoneW-w)*0.5, iPhoneH-h-64, w, h)];
    [ruleBtn setTitle:@"点击发送" forState:UIControlStateNormal];
    ruleBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [ruleBtn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    ruleBtn.backgroundColor = [UIColor clearColor];
    [ruleBtn addTarget:self action:@selector(clickBtn) forControlEvents:UIControlEventTouchUpInside];
}

- (void)clickBtn {
    NSLog(@"CLICK");
    [self sendPushNotification];
    
}

- (void)sendPushNotification {
    UILocalNotification *notification = [[UILocalNotification alloc] init];
    notification.fireDate=[NSDate dateWithTimeIntervalSinceNow:10];
    notification.timeZone=[NSTimeZone defaultTimeZone];
    notification.applicationIconBadgeNumber = 1; //设置右上角小圆圈数字为1
    notification.soundName= UILocalNotificationDefaultSoundName;
    notification.alertBody = @"推送测试s";
    [[UIApplication sharedApplication]  scheduleLocalNotification:notification];
}

@end
